package br.com.gr.jcash.util;

import java.io.InputStream;
import java.util.Properties;
import javax.faces.context.FacesContext;

/**
 *
 * @author gelson
 */
public class JcashResources {

    private static JcashResources instancia;
    private Properties props;

    private JcashResources() {
        init();
    }

    public static JcashResources getInstance() {
        if (instancia == null) {
            instancia = new JcashResources();
        }
        return instancia;
    }

    /**
     *
     */
    private void init() {

        try {

            props = new Properties();
            props.load(getClass().getResourceAsStream("/jcash.properties"));

        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    /**
     *
     * @param chave
     * @return
     */
    public String getProperty(String chave) {
        return props.getProperty(chave);
    }

    public InputStream getRelatorio(String nomeRelatorio) {
        FacesContext context = FacesContext.getCurrentInstance();
        return context.getExternalContext().getResourceAsStream(getProperty(nomeRelatorio));
//        return getClass().getResourceAsStream();
    }
}
